using System;
using System.Collections;
using System.Collections.Generic;
using Nirvana.Common;
using UnityEngine;

#if UNITY_EDITOR
using Newtonsoft.Json;
using UnityEngine.Playables;
#endif

namespace Nirvana.SkillEditor
{
    [Serializable]
    public abstract class SkillActionBase
    {
        [Nirvana.HideInInspector] public float delay;
        [Nirvana.HideInInspector] public float duration;

        [Nirvana.HideInInspector] private Skill _skill;
#if UNITY_EDITOR
        [JsonIgnore]
#endif
        public string title => GetType().Name.Replace("Action", "");
#if UNITY_EDITOR
        [JsonIgnore]
#endif
        protected Entry caster => _skill.caster;
#if UNITY_EDITOR
        [JsonIgnore]
#endif
        protected Entry target => _skill.target;
        
#if UNITY_EDITOR
        [JsonIgnore]
#endif
        protected List<Entry> targets => _skill.targets;

        public virtual void Init(Skill skill)
        {
            _skill = skill;
        }
        
        public virtual bool Running() { return false; }

#if UNITY_EDITOR
        [Nirvana.HideInInspector] public bool foldout = true;

        public virtual void OnGUI()
        {
            EditorUtils.DrawInspectorObjectFields(this);
        }

        public virtual void SetDelayAndDuration(double delay, double duration)
        {
            this.delay = (float) delay;
            this.duration = (float) duration;
        }
        
        public virtual void PrepareFrame(Playable playable, FrameData info) { }
        public virtual void ProcessFrame(Playable playable, FrameData info, object playerData) { }
#endif
    }
}